#include <stdio.h>

#define NumofScore 10
//函数原型
void fun1(float *score, float *minscore, float *maxscore, float *averagescore);
float *fun2(float score[]);

float RtnVal[3];

void PrintInfo(void)
{
    printf("My Name is : %s\n", "ZHANG");
    printf("My Student ID is : %s\n", "22156558");
}

void main()
{
    PrintInfo();
    float Score[NumofScore]= {69,78,80,98.5,67,85,74,83.5,87,93};

    float ScoreMin,ScoreMax,ScoreAvg;
    fun1(&Score,&ScoreMin,&ScoreMax,&ScoreAvg);
    printf("fun1\n"
           "The minimal score is %.1f\n"
           "The maximal score is %.1f\n"
           "The average score is %.1f\n",
           ScoreMin,ScoreMax,ScoreAvg);

    float *RtnVal_fun2;
    RtnVal_fun2 = fun2(Score);

    printf("fun2\n"
           "The minimal score is %.1f\n"
           "The maximal score is %.1f\n"
           "The average score is %.1f\n",
           RtnVal_fun2[0],*(RtnVal_fun2+1),*(RtnVal_fun2+2));


}

void fun1(float *score, float *minscore, float *maxscore, float *averagescore)
{
    float _ScoreMin,_ScoreMax,_ScoreAvg,_ScoreTotal;
    _ScoreMin = 99999;
    _ScoreMax= -99999;
    _ScoreTotal = 0;
    for (int i=0; i<NumofScore; i++)
    {
        _ScoreTotal = _ScoreTotal + *score;
        if (*score>_ScoreMax)
        {
            _ScoreMax = *score;
        }
        if (*score<_ScoreMin)
        {
            _ScoreMin = *score;
        }
        score++;
    }
    *minscore =  _ScoreMin;
    *maxscore=	_ScoreMax;
    *averagescore = _ScoreTotal/NumofScore;
}


float *fun2(float score[])
{
    //返回三个值，第一个为最小值，第二个为最大值，第三个为平均值
    float _ScoreMin,_ScoreMax,_ScoreAvg,_ScoreTotal;
    _ScoreMin = 99999;
    _ScoreMax= -99999;
    _ScoreTotal = 0;
    for (int i=0; i<NumofScore; i++)
    {
        _ScoreTotal = _ScoreTotal + score[i];
        if (score[i]>_ScoreMax)
        {
            _ScoreMax = score[i];
        }
        if (score[i]<_ScoreMin)
        {
            _ScoreMin = score[i];
        }
    }
    float RetVal[3];
    RtnVal[0] = _ScoreMin;
    RtnVal[1] = _ScoreMax;
    RtnVal[2] = _ScoreTotal/NumofScore;
    return &RtnVal;

}
